import Vue from 'vue'
import App from './App.vue'
import router from './router'
import axios from 'axios'
import './assets/css/color.css'
// 外部引用tag.css
import './assets/css/tag.css'
// vant2
import vant from "./vant.config";
Vue.use(vant)

Vue.prototype.$http = axios
Vue.config.productionTip = false

// 
router.beforeEach((to, from, next) => {

  // 判断是否登录
  let token = localStorage.token
  // 未登录
  if (!token && (to.name === 'cart' || to.name === 'user')) {
    next('/login')
  }
  else {
    next()
  }

})

new Vue({
  router,
  render: h => h(App),
  beforeCreate() {
    // 
    Vue.prototype.$bus = this // 全局事件总线
  },
}).$mount('#app')
